import React from 'react'
import { connect,useSelector,useDispatch} from '../react-redux'
import actionCreators  from '../store/actionCreators/counter1';

function Counter1(props){
    //状态映射函数 替代connect(mapStateToProps)
    let { number } = useSelector(state=>state.counter1);
    let dispatch = useDispatch();
    return (
        <div>
            <p>{number}</p>
            <button onClick={()=>dispatch(actionCreators.add1())}>+</button>
            <button onClick={()=>dispatch(actionCreators.minus1())}>-</button>
            <button onClick={()=>dispatch(actionCreators.thunkAdd())}>thunkAdd</button>
            <button onClick={()=>dispatch(actionCreators.promiseAdd())}>promiseAdd</button>
        </div>
    )
}

export default Counter1


